﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;

namespace GG.Data
{
    public class MyData
    {

        private string _conStringLog = ConfigurationManager.ConnectionStrings["GG_EmailLog_DBConnectionString"].ToString();
        private string _conString = ConfigurationManager.ConnectionStrings["GG_DBConnectionString"].ToString();
        
        public MyData()
        {
        }

        public void InsertMailCountLog(string applicationName)
        {
            SqlCommand _sqlCmd = null;
            SqlConnection _sqlConn = new SqlConnection();
            DataSet _dsOffLineQuotes = new DataSet();
            try
            {
                string islive = ConfigurationManager.AppSettings["IsLive"].ToString();
                _sqlConn.ConnectionString = _conStringLog;
                _sqlConn.Open();

                _sqlCmd = new SqlCommand();
                _sqlCmd.Connection = _sqlConn;
                _sqlCmd.CommandType = CommandType.StoredProcedure;
                _sqlCmd.CommandText = "sproctblGGEmailsLogInsertSingleItem";

                SqlParameter _sqlPara1 = new SqlParameter();
                _sqlPara1.ParameterName = "@IsLive";
                _sqlCmd.Parameters.Add(_sqlPara1);
                _sqlCmd.Parameters[0].Value = islive;

                SqlParameter _sqlPara2 = new SqlParameter();
                _sqlPara2.ParameterName = "@ApplicationName";
                _sqlCmd.Parameters.Add(_sqlPara2);
                _sqlCmd.Parameters[1].Value = applicationName;

                SqlParameter _sqlPara3 = new SqlParameter();
                _sqlPara3.ParameterName = "@EmailCount";
                _sqlCmd.Parameters.Add(_sqlPara3);
                _sqlCmd.Parameters[2].Value = 1;

                _sqlCmd.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
            }
            finally
            {
                if (_sqlCmd != null)
                {
                    _sqlCmd = null;
                }

                if (_sqlConn.State != ConnectionState.Closed)
                {
                    _sqlConn.Close();
                    _sqlConn = null;
                }
            }
        }
                
    }

}
